package com.kongjs.application.convert;

import com.kongjs.application.enums.OperationName;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Optional;

@Component
public class OperationNameConverter implements Converter<String, OperationName> {
    @Override
    public OperationName convert(String source) {
        Optional<OperationName> optional = Arrays.stream(OperationName.values()).filter(operationName -> operationName.getValue().equals(source)).findFirst();
        return optional.orElse(null);
    }
}
